c5ee0171176abd8e03f9987b79fca4ece3b282f7,src/master/model/PopulationSize.java,PopulationSize,parseAssignmentString,#String#List#Map#,75

Before Change


        // of maximum values location index variables can take.
        Map<String, PopulationType> popTypes = new HashMap<>();
        Map<String, Integer> varNameBoundsMap = new HashMap<>();
        new ParseTreeWalker().walk(new MASTERGrammarBaseListener() {

            @Override
            public void exitPopel(MASTERGrammarParser.PopelContext ctx) {

                PopulationType popType = null;
                for (PopulationType thisPopType : populationTypes) {
                    if (ctx.popname().IDENT().toString().equals(thisPopType.getName()))
                        popType = thisPopType;
                }

                if (popType == null) {
                    System.err.println("Uknown population type '"
                        + ctx.popname().IDENT() + "' in reaction string.");
                    System.exit(1);
                }

                popTypes.put(ctx.popname().IDENT().toString(), popType);

                if (ctx.loc() != null) {

                    if (ctx.loc().locel().size() != popType.dims.length) {
                        System.err.println("Population location vector"
                            + " length does not match length of dims vector.");
                        System.exit(0);
                    }

                    for (int i=0; i<ctx.loc().locel().size(); i++) {
                        if (ctx.loc().locel(i).IDENT() != null) {
                            String varName = ctx.loc().locel(i).IDENT().toString();
                            if (!varNameBoundsMap.containsKey(varName)) {
                                varNameBoundsMap.put(varName, popType.dims[i]);
                            } else {
                                if (varNameBoundsMap.get(varName)>popType.dims[i]) {
                                    varNameBoundsMap.put(varName, popType.dims[i]);
                                }
                            }
                        }
                    }
                }
            }

        }, assignmentParseTree);

        // Assemble list of variable names and array of variable bounds
        List<String> scalarVarNames = new ArrayList<>(varNameBoundsMap.keySet());

After Change


            double popSize = sizeExprValue[0];

            // Create population object
            walker.walk(new MASTERGrammarBaseListener() {

                @Override
                public void exitAssignment(@NotNull MASTERGrammarParser.AssignmentContext ctx) {
                    // Assemble loc

                    List<Integer> locList = new ArrayList<>();
                    if (ctx.loc() != null) {
                        for (MASTERGrammarParser.LocelContext locelCtx : ctx.loc().locel()) {
                            if (locelCtx.IDENT() == null) {
                                locList.add(Integer.parseInt(locelCtx.getText()));
                            } else {
                                String varName = locelCtx.IDENT().getText();
                                int varIdx = scalarVarNames.indexOf(varName);
                                locList.add(scalarVarVals[varIdx]);
                            }
                        }
                    }

                    int[] loc = new int[locList.size()];
                    for (int i=0; i<loc.length; i++)
                        loc[i] = locList.get(i);

                    popSizes.put(new Population(popType, loc), popSize);
                }
            }, assignmentParseTree);
        }
    }